package cn.com.baiwei.controller;

import cn.com.baiwei.pojo.Vip;
import cn.com.baiwei.service.impl.VipServiceImpl;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Vip)表控制层
 *
 * @author X_Q
 * @since 2021-09-14 19:09:07
 * @version 1.0
 */
@RestController
@RequestMapping("/vip")
@Api(value = "会员(Vip)管理",tags = "会员(Vip)管理")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class VipController {
    /**
     * 服务对象
     */
    @Resource
    private VipServiceImpl vipServiceImpl;


    
    /**
     * 查询所有数据
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectAll", method = RequestMethod.GET)
    @ApiOperation(value = "查询所有数据并且模糊查询手机号接口",notes = "查询所有数据并且模糊查询手机号接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vipPhone",value = "手机号",paramType = "query",dataType = "String",required = true),
    })
    public Map<String, Object> selectAll(String vipPhone) {
        return this.vipServiceImpl.selectAll(vipPhone);
    }
    
    /**
     * 通过主键删除单条数据
     *
     * @param vipPhone 手机号
     * @return 单条数据
     */
    @RequestMapping(value = "/deleteByPhone", method = RequestMethod.POST)
    @ApiOperation(value = "根据一个主键删除一条**记录的接口",notes = "根据一个主键删除一条**记录的接口",httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vipPhone",value = "手机号",paramType = "query",dataType = "String",required = true),
    })
    public Map<String, Object> deleteByPhone(@RequestParam("vipPhone") String vipPhone) {
        return this.vipServiceImpl.deleteByPhone(vipPhone);
    }
    

    
    /**
     * 通过手机号修改积分
     *
     * @param vip 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "/updateByPhone", method = RequestMethod.POST)
    @ApiOperation(value = " 通过手机号修改积分",notes = " 通过手机号修改积分",httpMethod = "POST")
    public Map<String, Object> updateById(@RequestBody @ApiParam(name = "vip",value = "pojo模型",required = true) Vip vip) {
        return this.vipServiceImpl.updateByPhone(vip);
    }
    
    /**
     * 新增单条会员
     *
     * @param vip 一个数据库对应的POJO数据对象
     * @return 返回插入的主键id
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    @ApiOperation(value = "新增会员",notes = "新增会员",httpMethod = "POST")
    public Map<String, Object> insert(@RequestBody @ApiParam(name = "vip",value = "pojo模型",required = true) Vip vip) {
        return this.vipServiceImpl.insert(vip);
    }

    @RequestMapping(value = "/selectByPhone", method = RequestMethod.GET)
    @ApiOperation(value = "查询手机号的接口",notes = "查询手机号的接口",httpMethod = "GET")
    public Map<String, Object> selectByPhone(@RequestParam @ApiParam(name = "vipPhone",value = "pojo模型",required = true) String vipPhone) {
        return this.vipServiceImpl.selectByPhone(vipPhone);
    }


}